//
//  j3RenderingEngine2.h
//  HJC3D
//
//  Created by HJC on 11-10-10.
//  Copyright 2011年 __MyCompanyName__. All rights reserved.
//

#ifndef _J3RENDERINGENGINE2_H_
#define _J3RENDERINGENGINE2_H_


#include "j3RenderingEngine.h"
#include <OpenGLES/ES2/gl.h>
#include <OpenGLES/ES2/glext.h>
#include <vector>




extern j3RenderingEngine* CreateRenderer2();


class j3RenderingEngine2 : public j3RenderingEngine 
{
public:
    j3RenderingEngine2();
    void initialize(int width, int height);
    void render() const;
    void updateAnimation(float timeStep);
    void onRotate(DeviceOrientation newOrientation);
    
     void onFingerUp(ivec2 location);
     void onFingerDown(ivec2 location);
     void onFingerMove(ivec2 oldLocation, ivec2 newLocation);
    
    
private:
    float rotationDirection() const;
    GLuint buildShader(const char* source, GLenum shaderType) const;
    GLuint buildProgram(const char* vShader, const char* fShader) const;
    void applyOrtho(float maxX, float maxY) const;
    void applyRotation(float degrees) const;
    void    initConeData();
    
    std::vector<Vertex> _cone;
    std::vector<Vertex> _disk;
    Animation _animation;
    
    float   _desiredAngle;
    float   _currentAngle;
    GLuint  _simpleProgram;
    
    GLuint   _framebuffer;
    GLuint  _colorRenderbuffer;
    GLuint  _depthRenderbuffer;
};




#endif